//
//  ViewController.m
//  WidgetTest
//
//  Created by 李明明 on 15/10/10.
//  Copyright © 2015年 李明明. All rights reserved.
//

#import "ViewController.h"
#import "UIButton+YButton.h"
#import "People+CoreDataProperties.h"
#import "Animal+CoreDataProperties.h"
#define a 3
#define b 8

#define RESULT(x,y)   (x) > (y)
#if RESULT(a,b)
#define kc a
#else 
#define kc b
#endif







#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

@interface ViewController ()

@end

@implementation ViewController
{
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    // 归档
    NSDictionary *dic = @{@"name":@"liming"};
    NSString *path = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) firstObject];
    path = [path stringByAppendingPathComponent:@"myname.txt"];
//    BOOL result = [NSKeyedArchiver archiveRootObject:dic toFile:path];
    [dic writeToFile:path atomically:YES];
//    NSDictionary *dict = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
    [path writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:nil];
    
    NSLog(@"%@", path);
    
    RESULT(a, b);
    NSLog(@"%d", kc);
    
    

}
- (IBAction)alertAction:(id)sender
{
    [self performSegueWithIdentifier:kAlertViewTest sender:nil];
}
- (void)nullAction
{
    
}
- (IBAction)buttonProtectAction:(id)sender
{
    [self performSegueWithIdentifier:kButtonProtect sender:nil];
}
- (IBAction)shareSheetAction:(id)sender
{
    [self performSegueWithIdentifier:kShareSheet sender:nil];
}
- (IBAction)buttonLineAction:(id)sender
{
    [self performSegueWithIdentifier:kLineTest sender:nil];
}

- (IBAction)animationAction:(id)sender
{
    [self performSegueWithIdentifier:kAnimation sender:nil];
}

- (IBAction)runtimeAction:(id)sender
{
    [self performSegueWithIdentifier:kRuntime sender:nil];
    
}
- (IBAction)coredata:(id)sender
{
    [self performSegueWithIdentifier:kCoreData sender:nil];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
